package com.sz.admin.ai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

@Configuration
public class DataSourceConfig {
    
    @Primary
    @Bean(name = "pgDemoJdbcTemplate")
    public JdbcTemplate pgDemoJdbcTemplate() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("org.postgresql.Driver");
        dataSource.setUrl("jdbc:postgresql://117.72.40.185:55432/demo");
        dataSource.setUsername("postgres");
        dataSource.setPassword("root");
        return new JdbcTemplate(dataSource);
    }

    @Bean(name = "pgOllamaJdbcTemplate")
    public JdbcTemplate pgOllamaJdbcTemplate() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("org.postgresql.Driver");
        dataSource.setUrl("jdbc:postgresql://117.72.40.185:55432/ollama");
        dataSource.setUsername("postgres");
        dataSource.setPassword("root");
        return new JdbcTemplate(dataSource);
    }

    @Bean(name = "pgAliyunJdbcTemplate")
    public JdbcTemplate pgAliyunJdbcTemplate() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("org.postgresql.Driver");
        dataSource.setUrl("jdbc:postgresql://117.72.40.185:55432/aliyun");
        dataSource.setUsername("postgres");
        dataSource.setPassword("root");
        return new JdbcTemplate(dataSource);
    }
}
